package com.yanqu.road.entity.activity.hsisland.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.hsisland.HsIslandPosition;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_activity_hs_island_island_data")
public class HsIslandIslandData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "分组ID", select = true, update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "商会ID", select = true, update = true)
    private String unionId;

    @FieldTypeAnnotation(desc = "层ID", select = true, update = true)
    private int floorId;

    @FieldTypeAnnotation(desc = "岛ID", select = true, update = true)
    private int islandId;

    @FieldTypeAnnotation(desc = "获得的海神之心数量")
    private int keyNum;

    @FieldTypeAnnotation(desc = "提前确定的4格地块组，k：x_y,v:4个格子的坐标")
    private Map<String, List<HsIslandPosition>> fourLaPositions = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "明灯开启的坐标组，连通后移除")
    private List<Set<String>> lightPositionList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "海神之心出现最小探索进度千分比")
    private int keyShowRate;

    @FieldTypeAnnotation(desc = "海神之心必现最小探索进度千分比")
    private int keyMustShowRate;

    @FieldTypeAnnotation(desc = "总事件数量")
    private int allEventNum;

    @FieldTypeAnnotation(desc = "总格子数量")
    private int allLaNum;

    @FieldTypeAnnotation(desc = "是否删除")
    private int delFlag;

    @FieldTypeAnnotation(desc = "创建时间")
    private long createTime;

    public HsIslandIslandData() {
    }

    public HsIslandIslandData(int activityId, int groupId, String unionId, int floorId, int islandId, Map<String, List<HsIslandPosition>> fourLaPositions, int keyShowRate, int keyMustShowRate, int allEventNum, int allLaNum) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.unionId = unionId;
        this.floorId = floorId;
        this.islandId = islandId;
        this.keyNum = 0;
        this.fourLaPositions = fourLaPositions;
        this.keyShowRate = keyShowRate;
        this.keyMustShowRate = keyMustShowRate;
        this.allEventNum = allEventNum;
        this.allLaNum = allLaNum;
        this.delFlag = 0;
        this.createTime = System.currentTimeMillis();
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getGroupId() {
        return groupId;
    }
    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public String getUnionId() {
        return unionId;
    }
    public void setUnionId(String unionId) {
        if (unionId == null){
            return;
        }
        if (this.unionId == null || !this.unionId.equals(unionId)) {
            this.unionId = unionId;
            setOp(DataStatus.Update);
        }
    }

    public int getFloorId() {
        return floorId;
    }
    public void setFloorId(int floorId) {
        if (this.floorId != floorId) {
            this.floorId = floorId;
            setOp(DataStatus.Update);
        }
    }

    public int getIslandId() {
        return islandId;
    }
    public void setIslandId(int islandId) {
        if (this.islandId != islandId) {
            this.islandId = islandId;
            setOp(DataStatus.Update);
        }
    }

    public int getKeyNum() {
        return keyNum;
    }

    public void setKeyNum(int keyNum) {
        if (this.keyNum != keyNum) {
            this.keyNum = keyNum;
            setOp(DataStatus.Update);
        }
    }

    public Map<String, List<HsIslandPosition>> getFourLaPositions() {
        return fourLaPositions;
    }

    public void setFourLaPositions(Map<String, List<HsIslandPosition>> fourLaPositions) {
        if (fourLaPositions == null){
            return;
        }
        if (this.fourLaPositions == null || !this.fourLaPositions.equals(fourLaPositions)) {
            this.fourLaPositions = fourLaPositions;
            setOp(DataStatus.Update);
        }
    }

    public int getKeyShowRate() {
        return keyShowRate;
    }

    public void setKeyShowRate(int keyShowRate) {
        if (this.keyShowRate != keyShowRate) {
            this.keyShowRate = keyShowRate;
            setOp(DataStatus.Update);
        }
    }

    public int getKeyMustShowRate() {
        return keyMustShowRate;
    }

    public void setKeyMustShowRate(int keyMustShowRate) {
        if (this.keyMustShowRate != keyMustShowRate) {
            this.keyMustShowRate = keyMustShowRate;
            setOp(DataStatus.Update);
        }
    }

    public int getAllEventNum() {
        return allEventNum;
    }

    public void setAllEventNum(int allEventNum) {
        if (this.allEventNum != allEventNum) {
            this.allEventNum = allEventNum;
            setOp(DataStatus.Update);
        }
    }

    public int getAllLaNum() {
        return allLaNum;
    }

    public void setAllLaNum(int allLaNum) {
        if (this.allLaNum != allLaNum) {
            this.allLaNum = allLaNum;
            setOp(DataStatus.Update);
        }
    }

    public int getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(int delFlag) {
        if (this.delFlag != delFlag) {
            this.delFlag = delFlag;
            setOp(DataStatus.Update);
        }
    }

    public long getCreateTime() {
        return createTime;
    }
    public void setCreateTime(long createTime) {
        if (this.createTime != createTime) {
            this.createTime = createTime;
            setOp(DataStatus.Update);
        }
    }

    public List<Set<String>> getLightPositionList() {
        return lightPositionList;
    }

    public void setLightPositionList(List<Set<String>> lightPositionList) {
        if (lightPositionList == null){
            return;
        }
        if (this.lightPositionList == null || !this.lightPositionList.equals(lightPositionList)) {
            this.lightPositionList = lightPositionList;
            setOp(DataStatus.Update);
        }
    }

    public void addLightPosition(Set<String> lightPosition){
        this.lightPositionList.add(lightPosition);
        setOp(DataStatus.Update);
    }

    public boolean removeLightPosition(Set<String> lightPosition){
        boolean flag = this.lightPositionList.remove(lightPosition);
        setOp(DataStatus.Update);
        return flag;
    }
}
